package com.java.singleton;

public class Student2 {
	// 属性
	private String stuName;
	private int stuAge;
	private String stuSex;
	/**
	 * 单例模式的构建
	 */
	// (1)创建一个单例模式的static变量
	private static Student2 student2;

	// (2)将所有的构造方法私有化处理
	private Student2() {
		// 不允许外部new调用
	}

	// (3)提供一个静态的统一访问入口
	public static Student2 getNewInstance() {
		// 第一次访问，判断是否单例模式的静态的实例对象是否进行了初始化处理
		if (student2 == null) {
			// 创建实例化对象
			student2 = new Student2();

		}

		return student2;

	}

	// 行为
	public void dostuding() {
		System.out.println(stuName + " is suding...   ");
	}
	// setter,getter

	public String getStuName() {
		return stuName;
	}

	public void setStuName(String stuName) {
		this.stuName = stuName;
	}

	public int getStuAge() {
		return stuAge;
	}

	public void setStuAge(int stuAge) {
		this.stuAge = stuAge;
	}

	public String getStuSex() {
		return stuSex;
	}

	public void setStuSex(String stuSex) {
		this.stuSex = stuSex;
	}
}
